package com.kyzh.core.adapters

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.gushenge.core.beans.Slide
import com.kyzh.core.R
import com.kyzh.core.utils.loadImage
import com.makeramen.roundedimageview.RoundedImageView
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder

class BannerAdapter(var context: Context):BaseBannerAdapter<Slide>() {

    override fun getLayoutId(viewType: Int): Int {
        return R.layout.item_homev3_recom_banner_item
    }

    override fun bindData(
        holder: BaseViewHolder<Slide>?,
        data: Slide?,
        position: Int,
        pageSize: Int
    ) {
        val bg: RoundedImageView? = holder?.findViewById(R.id.image)
        val icon: ImageView? = holder?.findViewById(R.id.ivGameIcon)
        val name: TextView? = holder?.findViewById(R.id.tvGameName)
        val type: TextView? = holder?.findViewById(R.id.tvGameType)
        val tvDetail: TextView? = holder?.findViewById(R.id.tvDetail)
        val bq: RecyclerView? = holder?.findViewById(R.id.bq)
        bg?.loadImage(data?.image)
        icon?.loadImage(data?.icon)
        name?.text = data?.game_name
        tvDetail?.text = data?.name
        type?.text = "${data?.point}  ${data?.type}"

        bq?.layoutManager = LinearLayoutManager(context, RecyclerView.HORIZONTAL, false)
        bq?.adapter = BqSoildAdapter(R.layout.bq_item, data?.biaoqian!!)
    }

}